package com.csap.framework.oauth2.server.service;

import com.csap.framework.annotation.apidoc.Description;
import com.csap.framework.oauth2.server.entity.ClientAllowUrlEntity;
import com.csap.mybatisplus.extension.service.BaseCsapService;
import com.csap.framework.oauth2.server.model.ClientAllowUrlModel;

import java.util.List;

/**
 * <p>
 * 应用允许授权的URL
 * </p>
 *
 * @author yangchengfu
 * @dateTime 2021-07-25 23:51:30
 */
@Description(value = "应用允许授权的URLService")
public interface ClientAllowUrlService extends BaseCsapService<ClientAllowUrlEntity, ClientAllowUrlModel, Long> {

    /**
     * 可用url
     *
     * @param clientId 客户端id
     * @return 可用范围带url
     */
    default List<String> allowUrl(String clientId) {
        return lambdaQuery()
                .select(ClientAllowUrlEntity::getAllowUrl)
                .eq(ClientAllowUrlEntity::getClientId, clientId)
                .listField(String.class)
                .get();
    }
}
